const http = require('http');
const fs = require('fs');

let index = "index";
let login = "login"
fs.readFile('./01/index.html', function (err, data) {
  index = data;
});

fs.readFile('./01/login.html', function (err, data) {
  login = data;
});


http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/html'});
  if(request.url == '/') {
    response.end(`<a href="http://127.0.0.1:8081/index">index</a>&nbsp;&nbsp;<a href="http://127.0.0.1:8081/login">login</a>`)
  }else if(request.url == '/index') {
    response.end(index.toString())
  } else if(request.url == '/login') {
    response.end(login.toString())
  }

}).listen(8081);

console.log('Server running at http://127.0.0.1:8081/');